package testcase;


import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import junitx.util.PrivateAccessor;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


import satir.SatirGame;
import satir.SatirTherapy;
import satir.framework.packaging.Packager.PackageExtractDestinactionWriteFailure;
import satir.framework.packaging.Packager.PackagerArchieveFileDestinationNotFoundException;
import satir.framework.packaging.Packager.PackagerArchieveFileToBeArchievedNotFoundException;
import satir.framework.packaging.Packager.PackagerArchieveZipFileWriteFailureException;
import satir.framework.packaging.Packager.PackagerExtractAchieveFileContentInvalidException;

/**
 * The Testing Class SatirTherapyTest_playGame_1.
 * 
 * @version 1.0 March 2012
 * @author Bill Chan
 * 
 */
public class SatirTherapyTest_playGame_1 extends TestCase {
	private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); 
	private final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); 
	
	/**
	 * Sets up the test fixture.
	 * 
	 * Called before every test case method.
	 */
	@Before
	public void setUp() throws Exception {
		   System.setOut(new PrintStream(outContent));     
		   System.setErr(new PrintStream(errContent)); 
	}
	
	/**
	 * Tears down the test fixture.
	 * 
	 * Called after every test case method.
	 */
	@After
	public void tearDown() throws Exception {
		   System.setOut(null);     
		   System.setErr(null); 
	}
	
	/**
	 * Step number: 1 
	 * Goal: Test whether can it activate the Satir Game or not
	 */
	
	@Test
	public void testPlayGame() {
		
		class testStub extends SatirGame{
			public void startGame() throws PackagerExtractAchieveFileContentInvalidException, PackageExtractDestinactionWriteFailure, PackagerArchieveFileDestinationNotFoundException, PackagerArchieveFileToBeArchievedNotFoundException, PackagerArchieveZipFileWriteFailureException {
				System.out.print("testing");
			}
		}
		testStub stub=new testStub();
	    SatirTherapy satirTherapy=new SatirTherapy(stub);
	    try {
			PrivateAccessor.invoke(satirTherapy, "playGame", null, null);
		} catch (Throwable e) {
			e.printStackTrace();
		}
	   	    
		assertEquals("testing", outContent.toString());
	}
}